﻿<navigation:Page xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"  x:Class="SilverlightProject.MainPage" 
           xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
           xmlns:common="clr-namespace:System.Windows;assembly=System.Windows.Controls"
           xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
           xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
           xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
           mc:Ignorable="d"
           xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
           d:DesignWidth="640" d:DesignHeight="480"
           Title="MainPage Page">
    <Grid x:Name="LayoutRoot">

        <ScrollViewer x:Name="pageScroll" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
            <Grid Width="Auto" Height="Auto">
                <Grid.RowDefinitions>
                    <RowDefinition Height="30" />
                    <RowDefinition Height="*" />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="200" />
                    <ColumnDefinition Width="1" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>

                <Rectangle Grid.Column="1" Grid.RowSpan="2" Fill="Blue" />

                <StackPanel x:Name="size" Grid.Column="0" Grid.Row="0" HorizontalAlignment="Left"  Margin="5">
                    <Button x:Name="btnSize" Content="最大化/还原" Click="btnSize_Click" />
                </StackPanel>

                <StackPanel x:Name="navigation" Grid.Column="0" Grid.Row="1" HorizontalAlignment="Left" Margin="5">
                    <StackPanel.Resources>
                        <common:HierarchicalDataTemplate x:Key="childTemplate" >
                            <TextBlock Text="{Binding Path=Title}" />
                        </common:HierarchicalDataTemplate>
                        <common:HierarchicalDataTemplate x:Key="treeTemplate" 
                                                         ItemsSource="{Binding Path=Children}" 
                                                         ItemTemplate="{StaticResource childTemplate}">
                            <TextBlock Text="{Binding Path=Title}" />
                        </common:HierarchicalDataTemplate>
                    </StackPanel.Resources>
                    <controls:TreeView x:Name="treeView"
                                       ItemsSource="{Binding}" 
                                       ItemTemplate="{StaticResource treeTemplate}"
                                       SelectedItemChanged="treeView_SelectedItemChanged">
                        <Style TargetType="controls:TreeViewItem">
                            <Setter Property="IsExpanded" Value="True" />
                        </Style>
                    </controls:TreeView>
                </StackPanel>

                <navigation:Frame x:Name="frame" Grid.Column="2" Grid.RowSpan="2" JournalOwnership="UsesParentJournal" />
            </Grid>
        </ScrollViewer>
    </Grid>
</navigation:Page>
